<template>
<div id="modify">
     <el-form ref="form" :model="users" label-width="80px">
        <el-form-item label="客户姓名">
            <el-input v-model="users.name"></el-input>
        </el-form-item>
        <el-form-item label="客户电话">
            <el-input v-model="users.phone"></el-input>
        </el-form-item>
        <!-- <el-form-item label="所属销售员">
            <el-input v-model="users.salespersonsId"></el-input>
        </el-form-item> -->
        <el-form-item>
            <el-button type="primary" @click="onSubmit(users._id)">确认修改</el-button>
        </el-form-item>
    </el-form>
</div>
 
</template>

<script>
import { createNamespacedHelpers } from "vuex";
const { mapState, mapMutations, mapActions } = createNamespacedHelpers("users");
export default {
    computed:{
        ...mapState(['users']),
    },
    watch: {
        users:{
            handler(val){
                this.setModify(val);
            }
        },
        deep:true,
        immediate:true
    },
     methods: {
         ...mapMutations(['setAdd','setModify']),
        ...mapActions(['addUsers','updateUsers','getUsers']),
        onSubmit(_id){
            // console.log(_id);
            this.updateUsers();
            this.getUsers();
            this.$router.push('/System/MyCustomerList');
        }
     }
}
</script>

<style lang="scss">
#modify{
    width: 90%;
    margin: 0 auto;
    .el-form{
        width: 90%;
        margin: 60px;
        .el-form-item{
            margin-bottom: 20px;
            label{
                margin-right: 20px;
                font-size: 17px;
            }
            .el-input{
                width: 80%;
                // margin: 20px;
            }
            .el-button{
                width: 80px;
                line-height: 30px;
            }
        }
    } 
}

</style>